package cn.iocoder.yudao.module.wine.controller.app.teamtype;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.wine.controller.admin.guaranteerecord.vo.GuaranteeRecordRespVO;
import cn.iocoder.yudao.module.wine.controller.app.teamtype.vo.AppTeamTypePageReqVO;
import cn.iocoder.yudao.module.wine.controller.app.teamtype.vo.AppTeamTypeRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.teamtype.TeamTypeDO;
import cn.iocoder.yudao.module.wine.service.guaranteerecord.GuaranteeRecordService;
import cn.iocoder.yudao.module.wine.service.teamtype.TeamTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;

@Tag(name = "App - 团长缴费等级")
@RestController
@RequestMapping("/wine/team-type")
@Validated
public class AppTeamTypeController {

    @Resource
    private TeamTypeService teamTypeService;

    @Resource
    private GuaranteeRecordService guaranteeRecordService;

    @GetMapping("/get")
    @Operation(summary = "获得团长缴费等级")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppTeamTypeRespVO> getTeamType(@RequestParam("id") Long id) {
        TeamTypeDO teamType = teamTypeService.getTeamType(id);
        return success(BeanUtils.toBean(teamType, AppTeamTypeRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "获得团长缴费等级列表")
    public CommonResult<List<AppTeamTypeRespVO>> getTeamTypePage(@Valid AppTeamTypePageReqVO pageReqVO) {
        List<TeamTypeDO> list = teamTypeService.getTeamTypeList(pageReqVO);
        return success(BeanUtils.toBean(list, AppTeamTypeRespVO.class));
    }

    @GetMapping("/user-list")
    @Operation(summary = "获得团长缴费记录列表")
    public CommonResult<List<GuaranteeRecordRespVO>> getTeamTypeList() {
        List<GuaranteeRecordRespVO> list = guaranteeRecordService.appGetGuaranteeRecordList();
        return success(list);
    }

}
